package com.xqm.springcloud.comsumer.controller;

import com.xqm.springcloud.pojo.UserInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @author ShiMing
 * @version 1.0
 * @name UserController
 * @description TODO
 * @date 2020/8/20
 */

@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;

    private static final String URI = "http://SPRING-CLOUD-DEPT-PROVIDER";

    @GetMapping("/userinfos/{phone}")
    public UserInfo userInfo(@PathVariable String phone) {
        return restTemplate.getForObject(URI + "/userinfos/" + phone, UserInfo.class);
    }

    @GetMapping("/userinfos")
    public List<?> userinfos() {
        return restTemplate.getForObject(URI + "/userinfos", List.class);
    }


}
